﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace WMI.NET.CIM
{
    /// <summary>
    /// The CIM_PhysicalMedia class represents types of documentation and storage medium, such as tapes, CD ROMs, and so on. This class is typically used to locate and manage removable media (versus media sealed with the media access device as a single package, such as hard disks). Sealed media, however, can also be modeled using this class when the media is associated with the physical package using the CIM_PackagedComponent relationship.
    /// </summary>
    public class CIM_PhysicalMedia : CIM_PhysicalComponent
    {
        private Nullable<UInt64> _Capacity;
        private Nullable<Boolean> _CleanerMedia;
        private string _MediaDescription;
        private Nullable<UInt16> _MediaType;
        private Nullable<Boolean> _WriteProtectOn;

        /// <summary>
        /// Number of bytes that can be read from, or written to, a media. This property is not applicable to hard copy (documentation) or cleaner media. Data compression should not be assumed, as it would increase the value in this property. For tapes, it should be assumed that no file marks or blank space areas are recorded on the media.
        /// </summary>
        public Nullable<UInt64> Capacity { get { return _Capacity; } }

        /// <summary>
        /// If TRUE, the physical media is used for cleaning purposes, not data storage.
        /// </summary>
        public Nullable<Boolean> CleanerMedia { get { return _CleanerMedia; } }

        /// <summary>
        /// Additional detail related to the MediaType enumeration. For example, if value 3 ("QIC Cartridge") is specified, this property would indicate whether the tape is wide or 1/4 inch, pre-formatted, Travan compatible, and so on.
        /// </summary>
        public string MediaDescription { get { return _MediaDescription; } }

        /// <summary>
        /// Type of physical media. The MediaDescription property provides more explicit definition of the media type.
        /// </summary>
        public Nullable<UInt16> MediaType { get { return _MediaType; } } //TODO Enum

        /// <summary>
        /// If TRUE, the media is currently write-protected by a physical mechanism, such as a protect tab on a floppy disk.
        /// </summary>
        public Nullable<Boolean> WriteProtectOn { get { return _WriteProtectOn; } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public CIM_PhysicalMedia(ManagementBaseObject mbo)
            : base(mbo)
        {
            _Capacity = mbo.GetUlongValue("Capacity");
            _CleanerMedia = mbo.GetBoolValue("CleanerMedia");
            _MediaDescription = mbo.GetStringValue("MediaDescription");
            _MediaType = mbo.GetUshortValue("MediaType");
            _WriteProtectOn = mbo.GetBoolValue("WriteProtectOn");
        }

    }
}
